<?php
header ( 'Content-Type:text/html; charset=UTF-8' );
$pdo = new PDO ( 'mysql:dbname=atm;charset=utf8', 'root' );
@$zcaccount = $_REQUEST ['zcaccount'];
@$zcpassword = $_REQUEST ['zcpassword'];
@$qrpassword = $_REQUEST ['qrpassword'];
$s = $pdo->prepare ( 'select * from username' );
$s->execute ();
$data = $s->fetchAll ( PDO::FETCH_NAMED );
if (! empty ( $zcaccount ) && ! empty ( $zcpassword )) {
	foreach ( $data as $value ) {
		if ($zcaccount == $value ['name']) {
			echo json_encode ( array (
					'zt' => false,
					'fhwb' => '用户已存在' 
			) );
			exit ;
		}
	}
	if ($zcpassword == $qrpassword) {
		$s = $pdo->prepare ( 'insert into username(name,password,ye) values(:name,:password,:ye)' );
		$isok = $s->execute ( array (
				'name' => $zcaccount,
				'password' => $qrpassword,
		        'ye'=>"250"
		) );
		if ($isok) {
			echo json_encode ( array (
				'zt' => true,
				'fhwb' => '注册成功' 
		) );
		} else {
		
			echo json_encode ( array (
				'zt' => false,
				'fhwb' => '注册失败' 
		) );
		}
	} else {
		echo json_encode ( array (
				'zt' => false,
				'fhwb' => '两次密码不一致' 
		) );
	}
} else {
	echo json_encode ( array (
			'zt' => false,
			'fhwb' => '帐号密码不能为空' 
	) );
}
?>